home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / GOFER / !GToC / h / prelude < prev   
Text File  |  1993-02-17  |  13KB  |  333 lines

  1. /* --------------------------------------------------------------------------
  2.  * prelude.h:   Copyright (c) Mark P Jones 1991-1993.   All rights reserved.
  3.  *              See goferite.h for details and conditions of use etc...
  4.  *              Gofer version 2.28 January 1993
  5.  *
  6.  * Basic data type definitions, prototypes and standard macros including
  7.  * machine dependent variations...
  8.  * ------------------------------------------------------------------------*/
  9.  
  10. #define const             /* const is more trouble than it's worth,...     */
  11. #include <stdio.h>
  12.  
  13. /*---------------------------------------------------------------------------
  14.  * To select a particular machine/compiler, just place a 1 in the appropriate
  15.  * position in the following list and ensure that 0 appears in all other
  16.  * positions:
  17.  *
  18.  * The letters UN in the comment field indicate that I have not personally
  19.  * been able to test this configuration yet and I have not heard from anybody
  20.  * else that has tried it.  If you run Gofer on one of these systems and it
  21.  * works (or needs patches) please let me know so that I can fix it and
  22.  * update the source.
  23.  *-------------------------------------------------------------------------*/
  24.  
  25. #define TURBOC   0      /* For IBM PC, using Turbo C 1.5                   */
  26. #define BCC      0      /* For IBM PC, using Borland C++ 3.1               */
  27. #define SUNOS    0      /* For Sun 3/Sun 4 running SunOs 4.x               */
  28. #define NEXTSTEP 0      /* For NeXTstep 3.0 using NeXT cc                  */
  29. #define NEXTGCC  0      /* For NeXTstep with gcc 2.x                       */
  30. #define MINIX68K 0      /* For Minix68k with gcc                        UN */
  31. #define AMIGA    0      /* For Amiga using gcc 2.2.2                    UN */
  32. #define HPUX     0      /* For HPUX using gcc                           UN */
  33. #define LINUX    0      /* For Linux using gcc                          UN */
  34. #define DJGPP    0      /* For DJGPP version 1.09 (gcc2.2.2) and DOS 5.0   */
  35. #define RISCOS   1      /* For Acorn DesktopC and RISCOS2 or 3             */
  36. #define ALPHA    0      /* For DEC Alpha with OSF/1 (32 bit ints, no gofc) */
  37. #define OS2      0      /* For IBM OS/2 2.0 using EMX GCC                  */
  38. #define SVR4     0      /* For SVR4 using GCC2.2                           */
  39. #define ULTRIX   0      /* For DEC Ultrix 4.x using GCC2.3.3               */
  40. #define AIX      0      /* For IBM AIX on RS/6000 using GCC                */
  41.  
  42. /*---------------------------------------------------------------------------
  43.  * To add a new machine/compiler, add a new macro line above, add the new
  44.  * to the appropriate flags below and add a `machine specific' section in the
  45.  * following section of this file.  Please send me details of any new machines
  46.  * or compilers that you try so that I can pass them onto others!
  47.  *
  48.  *   UNIX          if the machine runs fairly standard Unix
  49.  *   SMALL_GOFER   for 16 bit operation on a limited memory PC
  50.  *   REGULAR_GOFER for 32 bit operation using largish default table sizes
  51.  *   LARGE_GOFER   for 32 bit operation using larger default table sizes
  52.  *   JMPBUF_ARRAY  if jmpbufs can be treated like arrays.
  53.  *   DOS_IO        to use DOS style IO for terminal control
  54.  *   TERMIO_IO     to use Unix termio for terminal control
  55.  *   SGTTY_IO      to use Unix sgtty for terminal control
  56.  *   BREAK_FLOATS  to use two integers to store a float (or double)
  57.  *                 if SMALL_GOFER, then you *must* use BREAK_FLOATS == 1
  58.  *                 (assumes sizeof(int)==2, sizeof(float)==4).
  59.  *                 Otherwise, assuming sizeof(int)==sizeof(float)==4,
  60.  *                 BREAK_FLOATS == 0 will give you floats  for floating pt,
  61.  *                 BREAK_FLOATS == 1 will give you doubles for floating pt.
  62.  *   HAS_FLOATS    to indicate support for floating point
  63.  *-------------------------------------------------------------------------*/
  64.  
  65. #define UNIX          (SUNOS  | NEXTSTEP | HPUX | NEXTGCC | LINUX | AMIGA | \
  66.                        MINIX68K |ALPHA | OS2 | SVR4 | ULTRIX | AIX)
  67. #define SMALL_GOFER   (TURBOC | BCC)
  68. #define REGULAR_GOFER (RISCOS | DJGPP)
  69. #define LARGE_GOFER   (UNIX   | ALPHA)
  70. #define JMPBUF_ARRAY  (UNIX   | DJGPP | RISCOS)
  71. #define DOS_IO        (TURBOC | BCC | DJGPP)
  72. #define TERMIO_IO     (LINUX  | HPUX | OS2 | SVR4)
  73. #define SGTTY_IO      (SUNOS  | NEXTSTEP | NEXTGCC | AMIGA | MINIX68K | \
  74.                        ALPHA  | ULTRIX | AIX)
  75. #define BREAK_FLOATS  (TURBOC | BCC)
  76. #define HAS_FLOATS    (REGULAR_GOFER | LARGE_GOFER | BREAK_FLOATS)
  77.  
  78. /*---------------------------------------------------------------------------
  79.  * The following flags should be set automatically according to builtin
  80.  * compiler flags, but you might want to set them manually to avoid default
  81.  * behaviour in some situations:
  82.  *-------------------------------------------------------------------------*/
  83.  
  84. #ifdef  __GNUC__                        /* look for GCC 2.x extensions     */
  85. #if     __GNUC__ >= 2 && !NEXTSTEP      /* NeXT cc lies and says it's 2.x  */
  86. #define GCC_THREADED 1
  87.  
  88. /* WARNING: if you use the following optimisations to assign registers for
  89.  * particular global variables, you should be very careful to make sure that
  90.  * storage(RESET) is called after a longjump (usually resulting from an error
  91.  * condition) and before you try to access the heap.  The current version of
  92.  * main deals with this using everybody(RESET) at the head of the main read,
  93.  * eval, print loop
  94.  */
  95.  
  96. #ifdef  m68k                            /* global registers on an m68k     */
  97. #define GLOBALcar       asm("a4")
  98. #define GLOBALcdr       asm("a5")
  99. #define GLOBALsp        asm("a3")
  100. #endif
  101.  
  102. #ifdef  sparc                           /* global registers on a sparc     */
  103. /* sadly, although the gcc documentation suggests that the following reg   */
  104. /* assignments should be ok, experience shows (at least on Suns) that they */
  105. /* are not -- it seems that atof() and friends spoil things.               */
  106. /*#define GLOBALcar     asm("g5")*/
  107. /*#define GLOBALcdr     asm("g6")*/
  108. /*#define GLOBALsp      asm("g7")*/
  109. #endif
  110.  
  111. #endif
  112. #endif
  113.  
  114. #ifndef GCC_THREADED
  115. #define GCC_THREADED 0
  116. #endif
  117.  
  118. /*---------------------------------------------------------------------------
  119.  * Machine specific sections:
  120.  * Include any machine specific declarations and define macros:
  121.  *   local              prefix for locally defined functions
  122.  *   far                prefix for far pointers
  123.  *   allowBreak()       call to allow user to interrupt computation
  124.  *   FOPEN_WRITE        fopen *text* file for writing
  125.  *   FOPEN_APPEND       fopen *text* file for append
  126.  *-------------------------------------------------------------------------*/
  127.  
  128. #ifdef __STDC__           /* To enable use of prototypes whenever possible */
  129. #define Args(x) x
  130. #else
  131. #if (TURBOC | BCC)        /* K&R 1 does not permit `defined(__STDC__)' ... */
  132. #define Args(x) x
  133. #else
  134. #define Args(x) ()
  135. #endif
  136. #endif
  137.  
  138. #if     (TURBOC | BCC)
  139. #include <alloc.h>
  140. #define local              near pascal
  141. extern  int  kbhit         Args((void));
  142. #define allowBreak()       kbhit()
  143. #define FOPEN_WRITE        "wt"
  144. #define FOPEN_APPEND       "at"
  145. #define farCalloc(n,s)     farcalloc((unsigned long)n,(unsigned long)s)
  146. #define sigProto(nm)       int nm(void)
  147. #define sigRaise(nm)       nm()
  148. #define sigHandler(nm)     int nm()
  149. #define sigResume          return 1
  150. #endif
  151.  
  152. #if     SUNOS
  153. #include <malloc.h>
  154. #define far
  155. #define farCalloc(n,s)     (Void *)valloc(((unsigned)n)*((unsigned)s))
  156. #endif
  157.  
  158. #if     (NEXTSTEP | NEXTGCC | AMIGA | MINIX68K | ULTRIX)
  159. #include <stdlib.h>
  160. #define far
  161. #define farCalloc(n,s)     (Void *)valloc(((unsigned)n)*((unsigned)s))
  162. #endif
  163.  
  164. #if     (HPUX | DJGPP | LINUX | ALPHA | OS2 | SVR4 | AIX)
  165. #include <stdlib.h>
  166. #define far
  167. #endif
  168.  
  169. #if     RISCOS
  170. #include <string.h>
  171. #include <stdlib.h>
  172. #include <signal.h>
  173. #define  far
  174. #define  isascii(c)     (((unsigned)(c))<128)
  175. #define  Main           int
  176. #define  MainDone       return 0;/*NOTUSED*/
  177. extern   int access     Args((char *, int));
  178. #endif
  179.  
  180. #ifndef USE_READLINE
  181. #define USE_READLINE  0
  182. #endif
  183. #ifndef allowBreak
  184. #define allowBreak()
  185. #endif
  186. #ifndef local
  187. #define local
  188. #endif
  189. #ifndef farCalloc
  190. #define farCalloc(n,s)     (Void *)calloc(((unsigned)n),((unsigned)s))
  191. #endif
  192. #ifndef FOPEN_WRITE
  193. #define FOPEN_WRITE        "w"
  194. #endif
  195. #ifndef FOPEN_APPEND
  196. #define FOPEN_APPEND       "a"
  197. #endif
  198. #ifndef sigProto
  199. #define sigProto(nm)       Void nm Args((int))
  200. #define sigRaise(nm)       nm(1)
  201. #define sigHandler(nm)     Void nm(sig_arg) int sig_arg;
  202. #define sigResume          return
  203. #endif
  204. #ifndef Main                    /* to cope with systems that don't like    */
  205. #define Main               Void /* main to be declared as returning Void   */
  206. #endif
  207. #ifndef MainDone
  208. #define MainDone
  209. #endif
  210.  
  211. #if (UNIX | DJGPP | RISCOS)
  212. #define ctrlbrk(bh)        signal(SIGINT,bh)
  213. #endif
  214.  
  215. /*---------------------------------------------------------------------------
  216.  * General settings:
  217.  *-------------------------------------------------------------------------*/
  218.  
  219. #define Void     void   /* older compilers object to: typedef void Void;   */
  220. typedef unsigned Bool;
  221. #define TRUE     1
  222. #define FALSE    0
  223. typedef char    *String;
  224. typedef int      Int;
  225. typedef long     Long;
  226. typedef int      Char;
  227. typedef unsigned Unsigned;
  228.  
  229. #if     RISCOS
  230. #define STD_PRELUDE        "prelude"
  231. #else
  232. #define STD_PRELUDE        "standard.prelude"
  233. #endif
  234.  
  235. #define NUM_SYNTAX         100
  236. #define NUM_SELECTS        100
  237. #define NUM_FILES          20
  238. #define NUM_MODULES        64
  239. #define NUM_FIXUPS         100
  240. #define NUM_TUPLES         100
  241. #define NUM_OFFSETS        1024
  242. #define NUM_CHARS          256
  243.  
  244. /* Managing two different sized versions of Gofer has caused problems in
  245.  * the past for people who tried to change one setting, but inadvertantly
  246.  * modified the settings for a different size.  Now that we have three
  247.  * sizes of Gofer, I think it's time to try a new scheme:
  248.  */
  249.  
  250. #if     SMALL_GOFER                     /* the McDonalds mentality :-)     */
  251. #define Pick(s,r,l)        s
  252. #endif
  253. #if     REGULAR_GOFER
  254. #define Pick(s,r,l)        r
  255. #endif
  256. #if     LARGE_GOFER
  257. #define Pick(s,r,l)        l
  258. #endif
  259.  
  260. #define NUM_TYCON          Pick(60,    160,        160)
  261. #define NUM_NAME           Pick(625,   2000,       16000)
  262. #define NUM_CLASSES        Pick(20,    40,         40)
  263. #define NUM_INSTS          Pick(60,    100,        100)
  264. #define NUM_INDEXES        Pick(700,   2000,       2000)
  265. #define NUM_DICTS          Pick(400,   32000,      32000)
  266. #define NUM_TEXT           Pick(7000,  20000,      80000)
  267. #define NUM_TEXTH          Pick(1,     10,         10)
  268. #define NUM_TYVARS         Pick(800,   3000,       4000)
  269. #define NUM_STACK          Pick(1800,  16000,      16000)
  270. #define NUM_ADDRS          Pick(28000, 100000,     320000)
  271. #define MINIMUMHEAP        Pick(7500,  7500,       7500)
  272. #define MAXIMUMHEAP        Pick(32765, 0,          0)
  273. #define DEFAULTHEAP        Pick(28000, 100000,     100000)
  274. #define MAXPOSINT          Pick(32767, 2147483647, 2147483647)
  275.  
  276. #define minRecovery        Pick(1000,  1000,       1000)
  277. #define bitsPerWord        Pick(16,    32,         32)
  278. #define wordShift          Pick(4,     5,          5)
  279. #define wordMask           Pick(15,    31,         31)
  280.  
  281. #define bitArraySize(n)    ((n)/bitsPerWord + 1)
  282. #define placeInSet(n)      ((-(n)-1)>>wordShift)
  283. #define maskInSet(n)       (1<<((-(n)-1)&wordMask))
  284.  
  285. #ifndef __GNUC__
  286. #if !RISCOS
  287. extern Int      strcmp     Args((String, String));
  288. extern Int      strlen     Args((String));
  289. extern char     *strcpy    Args((String,String));
  290. extern char     *strcat    Args((String,String));
  291. #endif
  292. #endif
  293. extern char     *getenv    Args((char *));
  294. extern int      system     Args((char *));
  295. extern double   atof       Args((char *));
  296. extern char     *strchr    Args((char *,int));  /* test membership in str  */
  297. extern Void     exit       Args((Int));
  298. extern Void     internal   Args((String));
  299. extern Void     fatal      Args((String));
  300.  
  301. #if     HAS_FLOATS
  302. #ifdef  NEED_MATH
  303. #include <math.h>
  304. #endif
  305.  
  306. #if     (REGULAR_GOFER | MEDIUM_GOFER) & BREAK_FLOATS
  307. #define FloatImpType       double
  308. #define FloatPro           double
  309. #else
  310. #define FloatImpType       float
  311. #define FloatPro           double  /* type to use in prototypes            */
  312.                                    /* strictly ansi (i.e. gcc) conforming  */
  313.                                    /* but breaks data hiding :-(           */
  314. #endif
  315. #else
  316. #define FloatImpType       int     /*dummy*/
  317. #define FloatPro           int
  318. #endif
  319.  
  320. #ifndef FILENAME_MAX       /* should already be defined in an ANSI compiler*/
  321. #define FILENAME_MAX 256
  322. #else
  323. #if     FILENAME_MAX < 256
  324. #undef  FILENAME_MAX
  325. #define FILENAME_MAX 256
  326. #endif
  327. #endif
  328.  
  329. #define DEF_EDITOR         "vi"                 /* replace with ((char *)0)*/
  330. #define DEF_EDITLINE       "vi +%d %s"          /* if no default editor rqd*/
  331.  
  332. /*-------------------------------------------------------------------------*/
  333.